
import request from '@/utils/request';


export async function trafficList(params) {
  let url = `/tourism/api/v1/traffic/pageList`
  return request(url, {
    method: 'POST',
    body: {
      ...params
    },
  })
}
export async function trafficDetail(params) {
  let url = `/tourism/api/v1/traffic/${params.traffic_id}`
  return request(url, {
    method: 'POST',
    body: {
     // ...params
    },
  })
}
export async function editTraffic (params){
  let url = `/tourism/api/v1/traffic/update`
  return request(url, {
    method: 'POST',
    body: {
      ...params
    },
  })
}
export async function addTraffic(params) {
  let url = `/tourism/api/v1/traffic/inserte`;
  let filedata = new FormData();
  try {
    for(let item_nam in params){
      if (!params[item_nam]) continue;
      if (params[item_nam].parmsType && params[item_nam].parmsType ==='uploadFile'){
        params[item_nam].fileList.map((file)=>{
          filedata.append(item_nam,file.originFileObj);
        })
      }else {
        filedata.append(item_nam,params[item_nam])
      }
    }
    return request(url, {
      method: 'POST',
      body: filedata,
    })
  }catch (e){
    console.log(e);
  }

}
export async function updateFile(params) {
  let url = `/tourism/api/v1/traffic/fileUpdate`;
  let filedata = new FormData();
  try {
    for(let item_nam in params){
      if (!params[item_nam]) continue;
      if (params[item_nam].parmsType && params[item_nam].parmsType ==='uploadFile'){
        params[item_nam].fileList.map((file)=>{
          filedata.append(item_nam,file.originFileObj);
        })
      }else {
        filedata.append(item_nam,params[item_nam])
      }
    }
    return request(url, {
      method: 'POST',
      body: filedata,
    })
  }catch (e){
    console.log(e);
  }
}

export async function deleteFile(params) {
  let url = `/tourism/api/v1/traffic/deleteFile`
  return request(url, {
    method: 'POST',
    body: {
      ...params
    },
  })
}
export async function remove(params) {
  let url = `/tourism/api/v1/traffic/delete`
  return request(url, {
    method: 'POST',
    body: {
      ...params
    },
  })
}
